<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="activities" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="busOpportunityWorkRecordAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/BusOpportunityActivity?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 增加活动 </span>
          </div>
          <div>
            <el-row>
              <el-col :span="12">
                <el-form-item label="工作类型" prop="activities_worktype">
                  <el-select style='width:100%' v-model="activities.activities_worktype">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in wype" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="状态" prop="activities_state">
                  <el-select style='width:100%' v-model="activities.activities_state">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in state" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="安排给" prop="person_name">
                  <el-select style='width:100%' v-model="activities.person_id">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="时长" prop="activities_duration">
                  <el-input v-model="activities.activities_duration" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="单位" prop="activities_unit">
                  <el-select style='width:100%' v-model="activities.activities_unit">
                    <el-option label="分钟" value="分钟" />
                    <el-option label="小时" value="小时" />
                    <el-option label="天" value="天" />
                    <el-option label="周" value="周" />
                    <el-option label="月" value="月" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="开始日期" prop="activities_start">
                  <el-date-picker v-model="activities.activities_start" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="结束日期" prop="activities_end">
                  <el-date-picker v-model="activities.activities_end" type="date" style='width:100%' value-format="yyyy-MM-dd" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="联系人" prop="person_name">
                  <el-select style='width:100%' v-model="activities.person_name">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="主题" prop="activities_theme">
                  <el-input v-model="activities.activities_theme" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="备注" prop="activities_note">
                  <el-input type="textarea" v-model="activities.activities_note" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="优先级" prop="activities_priority">
                  <el-select style='width:100%' v-model="activities.activities_priority">
                    <el-option label="低" value="低" />
                    <el-option label="中" value="中" />
                    <el-option label="高" value="高" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="参与者" prop="person_name">
                  <el-select style='width:100%' v-model="activities.person_name">
                    <el-option label="－－无－－" value='' />
                    <el-option v-for="dict in person" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="时长" prop="activities_duration">
                  <el-input v-model="activities.activities_duration" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="单位" prop="activities_unit">
                  <el-select style='width:100%' v-model="activities.activities_unit">
                    <el-option label="分钟" value="分钟" />
                    <el-option label="小时" value="小时" />
                    <el-option label="天" value="天" />
                    <el-option label="周" value="周" />
                    <el-option label="月" value="月" />
                  </el-select>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="金额" prop="activities_amount">
                  <el-input v-model="activities.activities_amount" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="12">
                <el-form-item label="结果" prop="activities_results">
                  <el-input v-model="activities.activities_results" />
                </el-form-item>
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <el-form-item label="描述" prop="activities_description">
                  <el-input type="textarea" v-model="activities.activities_description" ttparea=350></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </div>
          <el-button @click="busOpportunityWorkRecordAddSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
          <el-button @click="gotoPage('/crm/sale/BusOpportunityActivity?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>取消</el-button>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'活动'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'BusOpportunityWorkRecordAdd',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        activities: {
          activities_worktype: null,
          activities_state: null,
          person_id: null,
          activities_duration: null,
          activities_unit: null,
          activities_start: null,
          activities_end: null,
          person_name: null,
          activities_theme: null,
          activities_note: null,
          activities_priority: null,
          person_name: null,
          activities_duration: null,
          activities_unit: null,
          activities_amount: null,
          activities_results: null,
          activities_description: null,
        },
        wype: [],
        state: [],
        person: [],
        person: [],
        person: [],
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "1BF69B6D830144DA817BDEE6290C9AEA",
        name: "商机管理",
        selected: "活动"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/crm/sale/PotentialAdmin/busOpportunityWorkRecordAdd?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      busOpportunityWorkRecordAddSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/crm/sale/PotentialAdmin/busOpportunityWorkRecordAddSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/crm/sale/BusOpportunityWorkRecordDet/busOpportunityWorkRecordDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
    },
  }
</script>
